package com.cmc.cloud.cmclink.doc.api.document;

import cn.hutool.core.bean.BeanUtil;
import com.cmc.cloud.cmclink.doc.api.document.rep.GuaranteeLetterRespDTO;
import com.cmc.cloud.cmclink.doc.api.document.req.GuaranteeLetterQueryReqDto;
import com.cmc.cloud.cmclink.doc.entity.GuaranteeLetterDO;
import com.cmc.cloud.cmclink.doc.service.GuaranteeLetterService;
import com.cmes.framework.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 长期保函查询
 *
 * @author zangfengyun
 */
@RestController
public class GuaranteeLetterApiImpl implements GuaranteeLetterApi {

    @Resource
    private GuaranteeLetterService guaranteeLetterService;

    /**
     * 客户常用保函查询
     *
     * @param guaranteeLetterQueryReqDto
     * @return
     */
    @Override
    public CommonResult<List<GuaranteeLetterRespDTO>> queryGuaranteeLetter(GuaranteeLetterQueryReqDto guaranteeLetterQueryReqDto) {

        List<GuaranteeLetterDO> guaranteeLetterDOList = guaranteeLetterService.queryGuaranteeLetterWeb(
                guaranteeLetterQueryReqDto.getBkpCodes(), guaranteeLetterQueryReqDto.getQueryTime());

        return CommonResult.success(BeanUtil.copyToList(guaranteeLetterDOList, GuaranteeLetterRespDTO.class));
    }
}
